window.onload = function () {

    var text = document.querySelector("input")
    var As = document.querySelectorAll("a")
    let Box = document.getElementsByClassName('progress-box')
    let Bar = document.getElementsByClassName("progress-bar")
    var PC = document.querySelector('.pc')
    var img = PC.querySelector('img')
    console.log(img);
    text.onfocus = function () {
        if (this.value === "告白气球") {
            this.value = ""
        }
    }
    text.onblur = function () {
        if (this.value === "") {
            this.value = "告白气球"
        }
    }
    // 音乐播放
    var audio = document.getElementById("Music");

    As[5].addEventListener('click', function () {
        PC.className = 'pc player'
        bf();
    }

    )
    function bf() {
        // var audio = document.getElementById('music1'); 
        if (audio !== null) {
            //检测播放是否已暂停.audio.paused 在播放器播放时返回false.
            if (audio.paused) {
                audio.play();//audio.play();// 这个就是播放  
            } else {
                audio.pause();// 这个就是暂停
            }
        }
    }
    As[6].addEventListener('click', function () {
        img.src = '../imgs/8.jpg'
    })
    As[4].addEventListener('click', function () {
        img.src = '../imgs/10.jpg'
    })
    As[7].addEventListener('click', function () {
        red()
    })
    function red() {
        if (As[7].style.color = 'aliceblue') {
            As[7].style.color = 'red'
        }
        // if (As[7].style.color = 'red'){
        //     As[7].style.color = 'aliceblue'
        // }
    }
    // 轮播图
    var oDiv = document.getElementById('miaovslide');
    var oUl = oDiv.getElementsByTagName('ul')[0];
    var aLi = oUl.getElementsByTagName('li');//获取所有的li
    var oUp = document.getElementById('up');//获取向上轮播的按钮
    var oDown = document.getElementById('down');//获取向下轮播的按钮
    var timer = null;//定义定时器
    var iSpeed = 0;//定义初始速度
    oUl.innerHTML + oUl.innerHTML; //实现循环无间断的图片流
    oUp.onmousedown = function () {
        timer = setInterval(doMove, 30);
        iSpeed = -5;

        //当按下向左的按钮时，设置速度为负，即向上滚动
    };
    oUp.onmouseup = function () {
        clearInterval(timer);
        //当抬起鼠标时，清除定时器
    };
    oDown.onmousedown = function () {
        iSpeed = 5;
        timer = setInterval(doMove, 30);
        //当鼠标按下向右的按钮时，设置速度为正，即向下滚动

    }
    oDown.onmouseup = function () {
        clearInterval(timer);
        //当鼠标抬起时，清除定时器

    }
    function doMove() {
        oUl.style.top = oUl.offsetTop + iSpeed + 'px';
        if (oUl.offsetTop < -oUl.offsetHeight / 1.2) {
            oUl.style.top = '0px';
        } else if (oUl.offsetTop > 0) {
            oUl.style.top = -oUl.offsetHeight / 1.2 + 'px';
        }
    };

    /**
     * 相关的页面跳转
     */
    var mpBtn = document.getElementById('main-page-btn');
    var spBtn = document.getElementById('song-page-btn');
    var btBtn = document.getElementById('but-tic-btn');
    var myBtn = document.getElementById('my-btn');

    mpBtn.onclick = function () {
        window.location.href = "../mainPage/mainPage.html"
    }

    spBtn.onclick = function () {
        window.location.href = "../songsPage/songsPage.html";
    }

    btBtn.onclick = function () {
        window.location.href = "../ticketBuying/ticketBuying.html"
    }

    myBtn.onclick = function () {
        window.location.href = "../loginPages/loginPages.html"
    }

}